<template>
  <div>
    <input type="file" ref="file" @change="uploadFile" />
  </div>
</template>

<script>
import uploadAxios from "axios";
const SERVICE_URL = "/upload";
export default {
  methods: {
    uploadFile() {
      let file = this.$refs.file.files[0];
      let formData = new FormData();
      formData.append("name", file.name);
      formData.append("file", file);
      var configs = {
        headers: {
          "Content-Type": "multipart/form-data"
        },
        onUploadProgress: e => {
          let completeProgress = (((e.loaded / e.total) * 100) | 0) + "%";
          console.log(completeProgress);
        }
      };
      uploadAxios
        .post(SERVICE_URL + "/upload/uploadFile", formData, configs)
        .then(res => {
          console.log(res);
        });
    }
  }
};
</script>

<style>
</style>